package com.example.computer_exam_training_sys.service.impl;

import com.example.computer_exam_training_sys.service.QuestionExplainService;
import com.example.computer_exam_training_sys.ultils.BaiduTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.SocketTimeoutException;

@Service
public class QuestionExplainServiceImpl implements QuestionExplainService {

    @Autowired
    private BaiduTokenUtil baiduTokenUtil;

    @Override
    public String explainQuestion(String questionContent, String answer, String analysis) throws SocketTimeoutException {
        StringBuilder prompt = new StringBuilder();
        prompt.append("请对以下题目内容、答案和解析进行更深入的思考和解释，帮助学生更好地理解知识点。\n");
        prompt.append("题目：").append(questionContent).append("\n");
        prompt.append("答案：").append(answer).append("\n");
        prompt.append("解析：").append(analysis).append("\n");
        prompt.append("请用通俗易懂的语言，结合相关知识点，给出更详细的解释和学习建议。");
        return baiduTokenUtil.getAnswer(prompt.toString());
    }
}
